import requests
from bs4 import BeautifulSoup
# 第三方开户定义成通用工具

def third_request(form_data):
    soup = BeautifulSoup(form_data, "html.parser")
    # HTML解析器
    three_soup_url = soup.form.get("action")
    three_data = {}
    for i in soup.find_all("input"):
        three_data[i.get("name")] = i.get("value")
    response = requests.post(three_soup_url, data=three_data)
    return response




# from bs4 import BeautifulSoup
# import requests
#
# def three_api(form_data):
#     # 安装html格式解释器
#     soup = BeautifulSoup(form_data,"html.parser")
#     # 获取URL
#     three_url = soup.form.get("action")
#     # 从html格式中提取数据
#     dir_info = {}
#     for i in soup.find_all("input"):
#         dir_info[i.get("name")]=i.get("values")
#     print(dir_info)
#     # 发送请求
#     response = requests.post(three_url,data=dir_info)
#     return response
